<template>
  <basic-container>
    <avue-crud
      ref="crud"
      v-model="form"
      :data="data"
      :option="option"
      :page.sync="page"
      :before-open="beforeOpen"
      @on-load="rowLoad"
      @search-change="searchChange"
      @row-del="rowDel"
      @size-change="sizeChange"
      @current-change="currentChange"
    >
    </avue-crud>
  </basic-container>
</template>

<script>
import avue from "@/mixins/avue.js";
import { trend_schCommentPage, comment_delete } from "@/api/sns";

export default {
  mixins: [avue],
  data() {
    return {
      data: [],
      option: {
        addBtn: false,
        editBtn: false,
        span: 8,
        labelWidth: "100",
        column: [
          {
            label: "评论人",
            prop: "fromName",
          },
          {
            label: "被回复人",
            prop: "toName",
          },
          {
            label: "评论内容",
            prop: "content",
          },
          {
            label: "评论时间",
            prop: "createTime",
          },
        ],
      },
    };
  },
  created() {},
  methods: {
    rowLoad() {
      trend_schCommentPage(this.params).then((res) => {
        let result = this.$s.res(res);
        this.data = result.records;
        this.page.total = result.total;
      });
    },
    rowDel(row, index, done) {
      this.$confirm("确定数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          comment_delete({ id: row.id }).then((res) => {
            this.$s.suc(res);
          });
        })
        .then(() => {
          this.rowLoad();
          done();
        });
    },
  },
  mounted() {},
};
</script>

<style lang="less" scoped>
.demo-drawer__content {
  width: 100%;
  padding: 20px;
}
</style>
